package cn.tedu;

import java.util.Objects;
import java.util.Scanner;

public class day12 {
    public static void main(String[] args) {
        Persion a=new Persion(50,"皮皮虾");
        System.out.println(a);
        Persion b=new Persion(50,"皮皮虾");
        System.out.println(b);
        System.out.println(a.equals(b));
        String line=new Scanner(System.in).nextLine();
         for(int i=0;i<line.length();i++){
             char ch =line.charAt(i);
             System.out.println("ch="+ch);
         }



    }
}
class Persion{
    public Persion(int age,String name){
        this.name=name;
        this.age=age;

    }
    private int age;

    public void setAge(int age) {
          this.age=age;
    }

    public int getAge() {if(age<0||age>150){
        System.out.println("请重新输入");
    }
        return age;
    }

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void eat(){
        System.out.println("吃饭");
    }
    public void sleep(){
        System.out.println("睡觉");
    }
    public Persion() {
        super();
    }

    @Override
    public String toString() {
        return "Persion{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Persion persion = (Persion) o;
        return age == persion.age &&
                Objects.equals(name, persion.name);
    }

}
